package cn.lxb.demo.service.impl;

import cn.lxb.demo.domain.entity.UserInfoEntity;
import cn.lxb.demo.mapper.UserInfoMapper;
import cn.lxb.demo.service.UserInfoService;
import cn.lxb.web.starter.template.sequence.Sequence;
import cn.lxb.web.starter.template.service.impl.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * spring-boot-web-template-starter test
 *
 * @author 54lxb
 * @since 2019-11-21
 */
@Service
public class UserInfoServiceImpl extends BaseServiceImpl<UserInfoMapper, UserInfoEntity, Long> implements UserInfoService {

    @Autowired
    private Sequence sequence;

    @Override
    protected void updateBefore(UserInfoEntity entity) {
        super.updateBefore(entity);
        entity.setUpdateTime(LocalDateTime.now());
    }

    @Override
    protected void updateAfter(UserInfoEntity entity) {
        super.updateAfter(entity);
    }

    @Override
    protected void deleteBefore(UserInfoEntity entity) {
        super.deleteBefore(entity);
    }

    @Override
    protected void deleteAfter(UserInfoEntity entity) {
        super.deleteAfter(entity);
    }

    @Override
    protected void insertBefore(UserInfoEntity entity) {
        super.insertBefore(entity);
        entity.setId(sequence.nextId());
        entity.setUpdateTime(LocalDateTime.now());
        entity.setCreateTime(LocalDateTime.now());
    }

    @Override
    protected void insertAfter(UserInfoEntity entity) {
        super.insertAfter(entity);
    }
}
